package Leetcode;
import tree.TreeNode;

import java.util.ArrayList;
import java.util.List;

/**
 * @ Author     ：侯耀祖
 * @ Description：
 */
public class isValidBST {
    TreeNode pre;
    boolean flag = true;
    public boolean isValidBST(TreeNode root) {
        isBST(root);
        return flag;
    }
    public void isBST(TreeNode root){
        if (root == null){
            return;
        }
        isValidBST(root.left);
        if (pre != null){
            if (pre.val >= root.val){
                flag = false;
            }
        }
        pre = root;
        isValidBST(root.right);
    }
}
